package com.mpyy.interceptor;

import com.mpyy.pojo.OperatorInfo;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * @version 1.0
 * @Description BankTransactionInterceptor
 * @Author YYJC
 * @Date 2022-01-14 10:26
 */
@Component
public class BankTransactionInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        System.out.println("调用了拦截器");
//        //1、通过request获取session再获取session中保存的用户对象
//        OperatorInfo operatorInfo = (OperatorInfo) request.getSession().getAttribute("USER_OPERATOR");
//        //2、判断
//        if(null != operatorInfo){ //2.1 session中有登录的用户对象，则直接放行去执行后续处理器操作
//            return true;
//        }
//        //2.2 通过重定向跳转至登录页面
//        response.sendRedirect("/mpyy/login.html");
//        System.out.println("成功拦截");
//        return false;
//    }
}
